package top.ljlgithub.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.ljlgithub.dao.BookDao;
import top.ljlgithub.domain.Book;
import top.ljlgithub.service.BookService;

import java.util.List;

/**
 * @ClassName
 * @Description TODO
 * @Author L1470
 * @Date 2021/3/16 17:32
 * @Version 1.0
 **/
public class BookServiceImpl implements BookService {
    //声明dao对象
    private BookDao bookDao;
    public void setBookDao(BookDao bookDao){
        this.bookDao = bookDao;
    }

    @Override
    public int addBook(Book book) {
        return bookDao.addBook(book);
    }

    @Override
    public int removeBookById(Integer id) {
        return bookDao.deleteBookById(id);
    }

    @Override
    public int updateBook(Book book) {
        return bookDao.updateBook(book);
    }

    @Override
    public Book findBook(Integer id) {
        return bookDao.findBookById(id);
    }

    @Override
    public List<Book> findBooks() {
        return bookDao.findBooks();
    }

    @Override
    public Book queryBook(String bookName) {
        Book book = bookDao.findBookByName(bookName);
        return book;
    }
}
